package com.imau.service.impl;


import com.imau.dao.BookDao;
import com.imau.bean.Book;
import com.imau.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookDao bookDao;
    public boolean save(Book book) {

        int row  = bookDao.addBook(book);

        return row > 0 ? true :false;
    }

    public boolean update(Book book) {
        int row  = bookDao.updateBook(book);

        return row > 0 ? true :false;
    }

    public boolean delete(Integer id) {
        int row  = bookDao.deleteBookById(id);

        return row > 0 ? true :false;
    }

    public Book getById(Integer id) {
        return bookDao.queryBookById(id);
    }

    public List<Book> getAll() {
        return bookDao.queryAllBook();
    }


}
